﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp1
{
    class Class1
    {
        public static DataTable GetDataTable(string sql)
        {
            string conString = "server=.;database=Student;uid = sa; pwd = 123456;";

            SqlConnection sqlConnection = new SqlConnection(conString);
            

            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, sqlConnection);

            DataTable dt = new DataTable();

            sqlConnection.Open();

            dataAdapter.Fill(dt);
            
            return dt;
        }
    }
}
